﻿<% if(@products.count == 0) %>
<p><b><font size = "4"> <%= t :ketqua%></font> </b></p>
<%else%>
<h1><font color="a3bc3fc" size = "6"> <%= t :dscacloainuoc%></font></h1>

<tr>
    <th></th>
    <th></th>
    <th></th>
    <th></th>
    <th></th>
    <th></th>
    <th></th>
  </tr>
<table class="table table-striped">
<% @products.each do |product| %>
  <tr>
    
    
    <% @des = product.Description %>
    <% @stdes = @des.to_s %>
    <% @print = @stdes[0..50] %>
    <% @aa = ProductImage.find_by_product_id(product.product_id) %>
    <% if (@aa!=nil)%>
    <% @tp = @aa.image%>
    <td><%= link_to image_tag(@tp, :height => '250', :width => '250', :alt =>"#{product.Name}"), product %><td>
    <%end%>
    <% @bb = Category.find(product.category_id)%>
    <td><p><h8><%= product.Name %></h8></a></p>
      <p><%= t :gia %>: <h8><%= product.Price %></h8></a><br/></p>  
      <p><%= t :theloai%>: <%=@bb.Name%></p>             
      <%= t :mieuta%>: <%=@print%>.....<br/>
      <a href="<%=@url_phat%>/shopcarts/new" ><img src="/images/buy/buy_now.jpg" alt="Buy" width="150" height="30"/>
        
      </a><br/>
      <%= link_to "#{t :chitiet}", product %>
    </td>
    <th></th>


    <th></th>

    <% if((session[:user_id])!=nil) %>
      <% @user = User.find(session[:user_id]) %>
      <% if(@user.GroupUserId==10) %>
        <td><%= link_to "#{t :edit}", edit_product_path(product) %></td>
        <td><%= link_to "#{t :destroy}", product, confirm: 'Are you sure?', method: :delete %></td>             
      <%end%>   
    <%end%>
        
  </tr>
<% end %>

</table>
<%end%>
<h6><%= will_paginate @products, :previous_label => t("previous"), :next_label => t("next") %></h6>